package com.akkainaction.router.group.actor.broadcast;

import akka.actor.ActorRef;
import akka.actor.Props;
import akka.actor.UntypedActor;
import akka.routing.FromConfig;

public class MasterWorker extends UntypedActor {

    private ActorRef router;

    @Override
    public void preStart() throws Exception {
        getContext().actorOf(Props.create(BroadWork1.class), "bw1");
        getContext().actorOf(Props.create(BroadWork2.class), "bw2");
        router = getContext().actorOf(FromConfig.getInstance().props(), "broadRouter");
    }

    @Override
    public void onReceive(Object msg) throws Exception {
        router.tell(msg, getSender());
    }
}
